/*
 * Copyright (C) 2017-2021
 * All rights reserved, Designed By
 * Copyright authorization contact 18814114118
 */
package com.shop.cereshop.commons.service.wallet;

import com.shop.cereshop.commons.domain.wallet.CereBuyerWallet;
import com.shop.cereshop.commons.domain.wallet.CereWalletTransaction;
import com.shop.cereshop.commons.domain.wallet.CereWalletRecharge;
import com.shop.cereshop.commons.domain.wallet.CereWalletWithdrawal;

import java.math.BigDecimal;
import java.util.List;

/**
 * 用户钱包服务接口
 * @author
 */
public interface CereBuyerWalletService {

    /**
     * 获取用户钱包信息
     * @param buyerUserId 用户ID
     * @return 钱包信息
     */
    CereBuyerWallet getWalletByUserId(Long buyerUserId);

    /**
     * 初始化用户钱包
     * @param buyerUserId 用户ID
     * @return 钱包信息
     */
    CereBuyerWallet initWallet(Long buyerUserId);

    /**
     * 更新钱包余额
     * @param buyerUserId 用户ID
     * @param amount 金额变动
     * @param transactionType 交易类型
     * @param orderId 关联订单号
     * @param description 交易描述
     * @return 是否成功
     */
    boolean updateBalance(Long buyerUserId, BigDecimal amount, Integer transactionType, String orderId, String description);

    /**
     * 冻结余额
     * @param buyerUserId 用户ID
     * @param amount 冻结金额
     * @param orderId 关联订单号
     * @param description 交易描述
     * @return 是否成功
     */
    boolean freezeBalance(Long buyerUserId, BigDecimal amount, String orderId, String description);

    /**
     * 解冻余额
     * @param buyerUserId 用户ID
     * @param amount 解冻金额
     * @param orderId 关联订单号
     * @param description 交易描述
     * @return 是否成功
     */
    boolean unfreezeBalance(Long buyerUserId, BigDecimal amount, String orderId, String description);

    /**
     * 获取钱包流水
     * @param buyerUserId 用户ID
     * @param page 页码
     * @param size 每页大小
     * @return 流水列表
     */
    List<CereWalletTransaction> getTransactionList(Long buyerUserId, Integer page, Integer size);

    /**
     * 创建充值订单
     * @param buyerUserId 用户ID
     * @param amount 充值金额
     * @param paymentMethod 支付方式
     * @return 充值订单
     */
    CereWalletRecharge createRechargeOrder(Long buyerUserId, BigDecimal amount, Integer paymentMethod);

    /**
     * 处理充值成功
     * @param rechargeNo 充值单号
     * @param thirdPartyOrderNo 第三方订单号
     * @return 是否成功
     */
    boolean handleRechargeSuccess(String rechargeNo, String thirdPartyOrderNo);

    /**
     * 申请提现
     * @param buyerUserId 用户ID
     * @param amount 提现金额
     * @param withdrawalMethod 提现方式
     * @param bankInfo 银行卡信息(银行卡提现时需要)
     * @return 提现订单
     */
    CereWalletWithdrawal applyWithdrawal(Long buyerUserId, BigDecimal amount, Integer withdrawalMethod, Object bankInfo);

    /**
     * 审核提现申请
     * @param withdrawalId 提现ID
     * @param auditResult 审核结果 1-通过 2-拒绝
     * @param auditRemark 审核备注
     * @param auditUserId 审核人ID
     * @return 是否成功
     */
    boolean auditWithdrawal(Long withdrawalId, Integer auditResult, String auditRemark, Long auditUserId);

    /**
     * 处理提现成功
     * @param withdrawalNo 提现单号
     * @param thirdPartyOrderNo 第三方订单号
     * @return 是否成功
     */
    boolean handleWithdrawalSuccess(String withdrawalNo, String thirdPartyOrderNo);

    /**
     * 设置支付密码
     * @param buyerUserId 用户ID
     * @param payPassword 支付密码
     * @return 是否成功
     */
    boolean setPayPassword(Long buyerUserId, String payPassword);

    /**
     * 验证支付密码
     * @param buyerUserId 用户ID
     * @param payPassword 支付密码
     * @return 是否验证成功
     */
    boolean verifyPayPassword(Long buyerUserId, String payPassword);

    /**
     * 修改支付密码
     * @param buyerUserId 用户ID
     * @param oldPassword 旧密码
     * @param newPassword 新密码
     * @return 是否成功
     */
    boolean modifyPayPassword(Long buyerUserId, String oldPassword, String newPassword);

    /**
     * 重置支付密码
     * @param buyerUserId 用户ID
     * @return 是否成功
     */
    boolean resetPayPassword(Long buyerUserId);

    /**
     * 检查支付密码是否被锁定
     * @param buyerUserId 用户ID
     * @return 是否锁定
     */
    boolean isPayPasswordLocked(Long buyerUserId);

    /**
     * 获取剩余锁定时间
     * @param buyerUserId 用户ID
     * @return 剩余锁定时间(分钟)
     */
    long getRemainingLockTime(Long buyerUserId);
}
